package Solutions;

import java.util.Arrays;

public class Solution13 {
    public static void main(String[] args) {
        Solution013 solution013 = new Solution013();
        System.out.println(solution013.checkDynasty(new int[]{1, 0, 0, 5, 4}));
    }
}
class Solution013 {
    public boolean checkDynasty(int[] places) {
        // 未知朝代数量n 也算是万能牌
        int n = 0;
        // 排序
        Arrays.sort(places);
        for(int i = 0; i < 4; i++) {
            if(places[i] == 0) {
                // 若有0则n+1
                n++;
            }
            else if(places[i] == places[i + 1]) {
                //若有重复则返回false
                return false;
            }
        }
        //0相当于是万能牌 最大号- 最小号 < 5 则连续
        return places[4] - places[n] < 5;
    }
}
